#ifndef FKSTARTER_H
#define FKSTARTER_H

#include <QCoreApplication>

#include <QVariant>

#include "FKFilesList.h"

class FKClientObjectManager;
class FKClient;
class QTextStream;

class FKStarter:public QCoreApplication{
    Q_OBJECT
public:
    FKStarter(int argc, char** argv);
    ~FKStarter();
signals:
    void requestClient(QString clientName, QString password);
    void requestClientCreation(QString clientName, QString password);
    void requestClientCreation(QString clientName, QString password, QVariant validator);
private slots:
    void restartApplication();
    void connectionLost();
    void message(QString m);
    void getCommand();
    void setClient(FKClient* c);
    void fileRecieved(QString fl);
    void fileRecievingError(QString fl);
    void bytesRecieved(QString fl, qint64 size);
private:
    void joinServer();
    void printHelp();
    void update();
    void logIn();
    void createClient();
    void addPostExecutionCommand(QString command);
    void checkForEnd();
    QString modifyWeight(qint64 bytes);
    QTextStream* _in;
    FKClientObjectManager* _manager;
    FKClient* _client;
    bool _inprogress;
    qint64 _totalToLoad;
    qint64 _loaded;
    qint16 _lastP;
    QStringList _downloading;
    QStringList _postCommands;
    QMap<QString,qint64> _sizes;
    FKFilesList ff;
};

#endif // FKSTARTER_H
